#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<cstring>
#include<cmath>

using namespace std;

char a[2000010], b[2000010];

int mn(char s[])
{
    int n = strlen(s + 1);
    for (int i = 1; i <= n; i++)   s[n + i] = s[i];
    int i = 1, j = 2, k;
    while (i <= n && j <= n)
    {
        for (k = 0; k < n && s[i + k] == s[j + k]; k++);
        if (k == n)    break;
        if (s[i + k] > s[j + k])
        {
            i += k + 1;
            if (i == j)    i++;
        }
        else
        {
            j += k + 1;
            if (i == j)    j++;
        }
    }
    return min(i, j);
}

int main()
{
    int x, y, lena, lenb;
    scanf("%s", a + 1);
    lena = strlen(a + 1);
    x = mn(a);
    scanf("%s", b + 1);
    lenb = strlen(b + 1);
    y = mn(b);
    a[x + lena] = b[y + lenb] = 0;
    if (lena == lenb && (!strcmp(a + x, b + y)))
    {
        cout << "Yes" << endl;
        puts(a + x);
    }
    else    cout << "No" << endl;
    return 0;
}
